home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 739 / hyper / help.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  5KB  |  162 lines

  1.  
  2. /******************  help.c  *********************
  3.  *                                               *
  4.  *                     HYPER                     *
  5.  *                                               *
  6.  *                                               *
  7.  *                  © by Koessi                  *
  8.  *                                               *
  9.  *             Thursday, 03 Sep 1992             *
  10.  *                                               *
  11.  *                                               *
  12.  *  this is an help showing the usage of         *
  13.  *  "hyper" from inside another program          *
  14.  *                                               *
  15.  *  Compile with DICE:                           *
  16.  *  dcc help.c -ohelp -rr -2.0                   *
  17.  *                                               *
  18.  *************************************************/
  19.  
  20. #include <exec/types.h>
  21. #include <exec/execbase.h>
  22. #include <exec/memory.h>
  23. #include <dos/dos.h>
  24. #include <dos/dostags.h>
  25. #include <rexx/storage.h>
  26.  
  27. /* Prototypes */
  28. #include <clib/exec_protos.h>
  29. #include <clib/dos_protos.h>
  30. #include <clib/alib_protos.h>
  31. #include <clib/rexxsyslib_protos.h>
  32.  
  33. #define  MSG struct Message
  34. #define RMSG struct RexxMsg
  35. #define MSGP struct MsgPort
  36. #define SIZE 32
  37.  
  38. extern void SendRxMsg(char *);
  39. extern void _main(int, char *);
  40. extern int   main(int, char **);
  41. /*
  42. int
  43. main(int argc, char **argv)
  44. {
  45.   return(FALSE);
  46. }
  47. */
  48.  
  49. /*************************************************
  50.  *                                               *
  51.  *                                               *
  52.  *    FUNCTION: _main                            *
  53.  *                                               *
  54.  *                                               *
  55.  *    INPUT:    short len                        *
  56.  *              char *arg                        *
  57.  *                                               *
  58.  *    OUTPUT:   int                              *
  59.  *                                               *
  60.  *    NOTE:     no cmdline parsing !             *
  61.  *                                               *
  62.  *************************************************/
  63.  
  64. char portname[] = "HYPER_RXPORT";
  65. char command[]  = "SYS:Utilities/hyper -b";
  66.  
  67. void
  68. _main(int arglen, char *argptr)
  69. {
  70.   if (!FindPort(portname))
  71.   {
  72.     SystemTags(command,
  73.                SYS_Asynch, TRUE,
  74.                SYS_Output, NULL,
  75.                SYS_Input,  NULL,
  76.                TAG_DONE);
  77.     Delay(10);
  78.   }
  79.   char *arg = argptr;
  80.   while (*argptr && *argptr != '\n')
  81.     ++argptr;
  82.  
  83.   *argptr = '\0';
  84.  
  85.   SendRxMsg(arg);
  86. }
  87.  
  88. /*************************************************
  89.  *                                               *
  90.  *                                               *
  91.  *    FUNCTION: SendRxMsg                        *
  92.  *                                               *
  93.  *                                               *
  94.  *    INPUT:    char *msgtxt                     *
  95.  *                                               *
  96.  *    OUTPUT:   void                             *
  97.  *                                               *
  98.  *    NOTE:     if e.g. input string is          *
  99.  *              formatted like this:             *
  100.  *              "IconAuthor/GADGETS"             *
  101.  *              this will cause 'hyper' to       *
  102.  *              search for a file called         *
  103.  *            a) "IconAuthor" in the             *
  104.  *                current directory              *
  105.  *            b) "HYPER:IconAuthor"              *
  106.  *            c) "HYPER:IconAuthor.hyper"        *
  107.  *            d) "HYPER:IconAuthor.guide"        *
  108.  *                                               *
  109.  *              If that file is found,           *
  110.  *              hyper will show the page         *
  111.  *              "GADGETS" if a node named        *
  112.  *              like that is found in the        *
  113.  *              database                         *
  114.  *                                               *
  115.  *************************************************/
  116.  
  117. void
  118. SendRxMsg(char *msgtxt)
  119. {
  120.   MSGP *reply_port;
  121.   MSGP *rx_port;
  122.   void *rx_msg;       /*  casted to parts of a RexxMsg struct */
  123.  
  124.   if (reply_port = CreateMsgPort())
  125.   {
  126.     if (rx_msg = AllocVec(sizeof(RMSG), MEMF_PUBLIC|MEMF_CLEAR))
  127.     {
  128.       ((struct Node *)rx_msg)->ln_Type      = NT_MESSAGE;
  129.       ((MSG         *)rx_msg)->mn_ReplyPort = reply_port;
  130.       ((MSG         *)rx_msg)->mn_Length    = sizeof(RMSG);
  131.       ((RMSG        *)rx_msg)->rm_Args[0]   = msgtxt;
  132.  
  133.       Forbid();
  134.       if (rx_port = (MSGP *)FindPort(portname))
  135.       {
  136.         PutMsg(rx_port, (MSG *)rx_msg);
  137.         Permit();
  138.         WaitPort(reply_port);
  139.         ReplyMsg(GetMsg(reply_port));
  140.       }
  141.       else
  142.         Permit();
  143.  
  144.       FreeVec(rx_msg);
  145.     }
  146.     DeleteMsgPort(reply_port);
  147.   }
  148. }
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.